package com.cz.background.controller.ey;


import cn.hutool.core.bean.BeanUtil;
import com.cz.background.dto.ey.*;
import com.cz.background.entity.ey.EySchedule;
import com.cz.background.service.ey.EyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/ey")
@Tag(name = "二院接口")
public class EyController {

    @Autowired
    private EyService eyService;

    @PostMapping("/getSourceInfo")
    @Operation(summary = "获取医生排班信息")
    public List<DoctorSchedule> getSourceInfo(@RequestBody ApiQueryScheduleDTO apiQueryScheduleDTO) {
        apiQueryScheduleDTO.setDeptCode("3002");
        apiQueryScheduleDTO.setHisAreaCode("06");
        apiQueryScheduleDTO.setTradeSource("05");
        return eyService.getSourceInfo(apiQueryScheduleDTO);
    }

    @PostMapping("/saveSchedule")
    @Operation(summary = "保存排班信息")
    public void saveSchedule(@Validated @RequestBody CreateScheduleDTO createScheduleDTO) {
        eyService.saveSchedule(createScheduleDTO);
    }


    @PostMapping("/querySchedule")
    @Operation(summary = "查询排班信息")
    public List<ScheduleDTO> querySchedule(@RequestBody QueryScheduleDTO queryScheduleDTO) {
        List<EySchedule> scheduleList = eyService.querySchedule(queryScheduleDTO);
        return BeanUtil.copyToList(scheduleList, ScheduleDTO.class);
    }


    @PostMapping("/delSchedule")
    @Operation(summary = "删除排班信息")
    public void delSchedule(@RequestBody EnableScheduleDTO enableScheduleDTO) {
         eyService.deleteSchedule(enableScheduleDTO);
    }

    @PostMapping("/enableAndDisable")
    @Operation(summary = "启用/禁用排班信息")
    public void enableAndDisable(@RequestBody EnableScheduleDTO enableScheduleDTO) {
        eyService.enableAndDisable(enableScheduleDTO);
    }


    @PostMapping("/queryDoctor")
    @Operation(summary = "查询医生列表")
    public List<DoctorDTO> queryDoctor() {
      return eyService.queryDoctorList();
    }
}
